package School_test;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        boolean isReceivingCipher = false; // 标记是否处于接收密文的状态
        StringBuilder cipherText = new StringBuilder(); // 存储当前数据集的密文

        while (scanner.hasNextLine()) {
            String line = scanner.nextLine();

            // 终止条件：遇到ENDOFINPUT，退出循环
            if ("ENDOFINPUT".equals(line)) {
                break;
            }

            // 开始接收密文：遇到START，重置密文缓冲区并标记状态
            if ("START".equals(line)) {
                isReceivingCipher = true;
                cipherText.setLength(0); // 清空之前的密文
                continue;
            }

            // 结束接收密文：遇到END，解密并输出
            if ("END".equals(line)) {
                isReceivingCipher = false;
                String plainText = decrypt(cipherText.toString());
                System.out.println(plainText);
                continue;
            }

            
            if (isReceivingCipher) {
                cipherText.append(line);
            }
        }

        scanner.close();
    }

  
    private static String decrypt(String cipher) {
        StringBuilder plain = new StringBuilder();
        for (char c : cipher.toCharArray()) {
            if (c >= 'A' && c <= 'Z') {
                int cipherIndex = c - 'A'; 
                int plainIndex = (cipherIndex - 5) % 26;
                if (plainIndex < 0) {
                    plainIndex += 26;
                }
                plain.append((char) (plainIndex + 'A'));
            } else {
                plain.append(c);
            }
        }
        return plain.toString();
    }
}
